home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / System / Swatch / Development / swatch 1.2 / swatch INIT / drvr.csOpen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-15  |  1.9 KB  |  122 lines  |  [TEXT/KAHL]

  1. /**
  2.  
  3.     drvr.csOpen.c
  4.     Copyright (c) 1990, joe holt
  5.  
  6.  **/
  7.  
  8.  
  9. /**-----------------------------------------------------------------------------
  10.  **
  11.  ** Headers
  12.  **
  13.  **/
  14.  
  15. #include "post.init.error.h"
  16. #include "init.resources.h"
  17. #include "drvr.patches.h"
  18. #include "drvr.csOpen.h"
  19.  
  20.  
  21. /**-----------------------------------------------------------------------------
  22.  **
  23.  ** Private Variables
  24.  **
  25.  **/
  26.  
  27. Boolean already_open = FALSE;
  28.  
  29.  
  30. /*******************************************************************************
  31.  **
  32.  **    Public Variables
  33.  **
  34.  **/
  35.  
  36. SysEnvRec The_world;
  37. int16 INIT_RefNum;
  38.  
  39.  
  40. /*******************************************************************************
  41.  **
  42.  **    Public Functions
  43.  **
  44.  **/
  45.  
  46. OSErr csOpen( CntrlParam *cpb, DCtlPtr dce )
  47. {
  48.     register int16 i;
  49.     register int16 init_error_strx;
  50.     KeyMap keymap;
  51.  
  52.     INIT_RefNum = dce->dCtlRefNum;
  53.  
  54.     if ( already_open )
  55.         return noErr;
  56.  
  57.     TheZone = SysZone;
  58.     init_error_strx = 0;
  59.  
  60.  
  61.     /**
  62.      **   If our global storage wasn't allocated, error
  63.      **/
  64.  
  65.     if ( !dce->dCtlStorage ) {
  66.         init_error_strx = NOT_ENOUGH_MEMORY_STRx;
  67.         goto exit;
  68.     }
  69.  
  70.  
  71.     /**------------------------------------------------------------
  72.      **
  73.      **   Initialize INIT
  74.      **
  75.      **/
  76.  
  77.  
  78.     /**
  79.      **   works only with System 6.0.3 or greater
  80.      **/
  81.  
  82.     SysEnvirons( 1, &The_world );
  83.     if ( The_world.systemVersion < 0x0603 ) {
  84.         init_error_strx = BAD_SYSTEM_VERSION_STRx;
  85.         goto exit;
  86.     }
  87.  
  88.  
  89.     /**
  90.      **   Not necessary to use the INIT with system 7
  91.      **/
  92.  
  93.     if ( The_world.systemVersion >= 0x0700 ) {
  94.         init_error_strx = DONT_NEED_INIT_STRx;
  95.         goto exit;
  96.     }
  97.  
  98.  
  99.     if ( Install_patches() ) {
  100.         init_error_strx = NOT_ENOUGH_MEMORY_STRx;
  101.         goto exit;
  102.     }
  103.  
  104.  
  105.     /**------------------------------------------------------------
  106.      **
  107.      **   End of initialization
  108.      **
  109.      **/
  110.  
  111.     DetachResource( dce->dCtlDriver );
  112.  
  113. exit:
  114.     if ( init_error_strx )
  115.         Post_init_error( init_error_strx );
  116.  
  117.     TheZone = ApplZone;
  118.     return ( init_error_strx ? notOpenErr : noErr );
  119. }
  120.  
  121.  
  122.